package com.cl.pile.rule.filter;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.math.BigDecimal;

/**
 * @author chenyitao
 * @date 2021/4/19
 */
public class LtFilterOperation implements IFilterOperation {
    @Override
    public boolean filterMatch(Object value, String matchValue) {
        if (StringUtils.isBlank(String.valueOf(value)) || StringUtils.isBlank(matchValue)) {
            return false;
        }
        if ( NumberUtils.isDigits(String.valueOf(value))&& NumberUtils.isDigits(matchValue)) {
            BigDecimal num1 = new BigDecimal(String.valueOf(value));
            BigDecimal num2 = new BigDecimal(matchValue);
            return num1.compareTo(num2) < 0;
        } else {
            return false;
        }
    }

    @Override
    public String filterName() {
        return "小于";
    }
}
